package com.whxy02.tolearn.app.config;

import com.whxy02.tolearn.app.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AdminInterceptorConfig implements WebMvcConfigurer {

    @Bean
    AdminInterceptor getAdminInterceptor(){
        return new AdminInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] cut={"/admin*","/admin/**"};
        String[] pas={};
        registry.addInterceptor(getAdminInterceptor()).addPathPatterns(cut).excludePathPatterns(pas);
    }
}